<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>

<!-- RichFaces tag library declaration -->
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<f:loadBundle basename="com.es.resource.messages" var="bundle" />
<f:loadBundle basename="com.es.resource.BusinessRules" var="bundleBR" />

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>


	<head>

		<script>
            function toggleRadioButton(radio) {
          
            var tempId = radio.name;
            var el = radio.form.elements;
            var id;
          
            id = getCustomId(tempId);
                 
            for (var i = 0; i < el.length; i++) {
                if ( getCustomId(el[i].name) == id) {
                    el[i].checked = false;
                }
            }
            radio.checked = true;
               
        }
        

            
         function getCustomId (tempId){
         	var id;
        	var splitted=tempId.split(':');
        	if(splitted.length>=2){
				id = splitted[0]+':'+splitted[1]+':'+splitted[2];
				return id; 
			}
        }
          
    </script>



	</head>

	<body>
		<f:view>
			<br>

			<rich:panel id="panel" style="width: 800px; height: 749px"
				header="#{bundle.LEAD_QUALIFICATION_CHECK_HEADER}">

				<h:inputHidden id="hiddenFieldForInit"
					value="#{leadConversionController.tempVarCLQ}"></h:inputHidden>


				<a4j:form id="f1">

					<rich:dataTable rowKeyVar="rowIndex"
						value="#{leadConversionController.leadQualificationPropertyValueBOList}"
						binding="#{leadConversionController.leadQualificationBODataTable}"
						var="propertyValueBO" width="400" border="0">

						<rich:column rendered="#{propertyValueBO.property.type == 'M'}"
							style=" border=0">


							<rich:dataTable value="#{propertyValueBO.valueBOlist}"
								rowKeyVar="rowIndexC" var="value" width="400" border="0"
								columns="2">


								<f:facet name="header">
									<rich:columnGroup>
										<rich:column style=" text-align:left" colspan="2">
											<h:outputText value="#{propertyValueBO.property.name}"></h:outputText>

										</rich:column>
									</rich:columnGroup>
								</f:facet>

								<rich:column width="14" style="border=0">
									<h:selectBooleanCheckbox value="#{value.isselected}">
									</h:selectBooleanCheckbox>
								</rich:column>


								<rich:column style="border=0">
									<h:outputText value="#{value.value}"></h:outputText>
								</rich:column>




							</rich:dataTable>


						</rich:column>



						<rich:column rendered="#{propertyValueBO.property.type == 'S'}"
							style=" border=0">

							<a4j:form id="f2">
								<rich:dataTable rowKeyVar="rowIndex"
									value="#{propertyValueBO.valueBOlist}"
									binding="#{leadConversionController.radioValueDataTable}"
									var="value" width="400" border="0">


									<f:facet name="header">
										<rich:columnGroup>
											<rich:column style=" text-align:left" colspan="2">
												<h:outputText value="#{propertyValueBO.property.name}"></h:outputText>

											</rich:column>
										</rich:columnGroup>
									</f:facet>


									<rich:column width="14" style=" border=0">
										<h:selectOneRadio onclick="toggleRadioButton(this);">
											<f:selectItem itemValue="null" />

											<a4j:support event="onchange" ajaxSingle="true"
												immediate="true"
												action="#{leadConversionController.setSelected}">
											</a4j:support>

										</h:selectOneRadio>

									</rich:column>



									<rich:column style="border=0">
										<h:outputText value="#{value.value}"></h:outputText>
									</rich:column>

								</rich:dataTable>

							</a4j:form>

						</rich:column>


					</rich:dataTable>

					<br>

					<a4j:commandButton id="saveButton" style="width: 108px"
						action="#{leadConversionController.submitValues}" value="Save"
						disabled="#{leadConversionController.saveButtonIsDisabled}"
						reRender="msg">
					</a4j:commandButton>

					<rich:spacer width="7"></rich:spacer>

					<a4j:commandButton id="cancelButton" style="width: 108px"
						action="#{leadConversionController.navigateToViewLeads}" value="Later">
					</a4j:commandButton>


					<br>
					<br>

					<rich:message id="msg" showSummary="true" for="saveButton"
						style='color:red; font-size: 11px;'>
					</rich:message>
					<br>
					<br>

					<rich:messages showSummary="true"
						style='color:red; font-size: 11px;'>
					</rich:messages>


				</a4j:form>

			</rich:panel>

		</f:view>
	</body>
</html>